<template>
  <div class="app-container">
    <!-- 日报管理-管理按钮 -->
    <div class="search-bar">
      <el-input v-model="searchData.rbId" placeholder="请输入主键查询" />
      <el-input v-model="searchData.jrzj" placeholder="请输入今日总结查询" />
      <el-input v-model="searchData.mrjh" placeholder="请输入明日计划查询" />
      <el-date-picker
        v-model="searchData.createTime"
        value-format="yyyy-MM-dd HH:mm:ss"
        style="margin-right: 10px"
        range-separator="至"
        start-placeholder="开始日期"
        end-placeholder="结束日期"
        type="daterange"
      />
      <el-date-picker
        v-model="searchData.updateTime"
        value-format="yyyy-MM-dd HH:mm:ss"
        style="margin-right: 10px"
        range-separator="至"
        start-placeholder="开始日期"
        end-placeholder="结束日期"
        type="daterange"
      />
      <el-input v-model="searchData.jsyId" placeholder="请输入技术员id查询" />
      <el-input v-model="searchData.jsyxm" placeholder="请输入技术员姓名查询" />
      <el-button
        v-waves
        type="primary"
        size="small"
        icon="el-icon-search"
        @click="searchBtnHandle"
        >查询</el-button
      >
      <el-button
        v-waves
        type="info"
        size="small"
        icon="el-icon-refresh"
        @click="resetTableList"
        >显示全部</el-button
      >
      <div style="float: right">
        <el-button
          v-waves
          type="primary"
          icon="el-icon-plus"
          @click="openAdd"
          size="small"
          v-permission="'jtnc-rbgl-krRbgl-add'"
          >新增
        </el-button>
        <el-button
          v-waves
          type="info"
          icon="el-icon-edit"
          @click="openUpdate(null)"
          size="small"
          v-permission="'jtnc-rbgl-krRbgl-update'"
          >修改
        </el-button>
        <el-button
          v-waves
          type="danger"
          icon="el-icon-delete"
          @click="deleteByIds(null)"
          size="small"
          v-permission="'jtnc-rbgl-krRbgl-delete'"
          >删除
        </el-button>
        <el-upload
          v-permission="'jtnc-rbgl-krRbgl-importExcel'"
          style="display: inline-block; margin: 0px 10px"
          :action="$baseServer + '/jtnc/rbgl/krRbgl/import/excel'"
          :headers="$store.getters.headerToken"
          :on-success="importExcelSuccess"
          accept=".xls,.xlsx"
          :show-file-list="false"
          :auto-upload="true"
        >
          <el-button v-waves type="warning" icon="el-icon-upload2" size="small"
            >批量导入</el-button
          >
        </el-upload>
        <el-button
          v-waves
          type="success"
          icon="el-icon-printer"
          @click="exportExcel"
          size="small"
          v-permission="'jtnc-rbgl-krRbgl-exportExcel'"
          >批量导出
        </el-button>
      </div>
    </div>
    <!-- 日报管理-列表 -->
    <el-table
      ref="dataTable"
      :data="tableData"
      stripe
      border
      @selection-change="handleTableSelectChange"
      v-loading="isLoading"
    >
      <el-table-column
        type="selection"
        width="50"
        align="center"
        header-align="center"
      />
      <el-table-column label="主键" prop="rbId" align="center" />
      <el-table-column label="今日总结" prop="jrzj" align="center" />
      <el-table-column label="明日计划" prop="mrjh" align="center" />
      <el-table-column label="提交日期" prop="createTime" align="center" />
      <el-table-column label="更新日期" prop="updateTime" align="center" />
      <el-table-column label="技术员id" prop="jsyId" align="center" />
      <el-table-column label="技术员姓名" prop="jsyxm" align="center" />
      <el-table-column fixed="right" label="操作" width="120" align="center">
        <template v-slot="scope">
          <el-button
            type="text"
            style="color: #13ce66"
            size="small"
            @click="openView(scope.row)"
            >详情</el-button
          >
          <el-button
            v-permission="'jtnc-rbgl-krRbgl-update'"
            type="text"
            size="small"
            @click="openUpdate(scope.row)"
            >修改
          </el-button>
          <el-button
            v-permission="'jtnc-rbgl-krRbgl-delete'"
            style="color: #ff6d6d"
            type="text"
            size="small"
            @click="deleteByIds(scope.row)"
            >删除
          </el-button>
        </template>
      </el-table-column>
    </el-table>
    <!-- 日报管理-分页 -->
    <el-pagination
      style="text-align: center; margin-top: 10px"
      layout="total,prev,pager,next,sizes,jumper"
      :page-size="pager.limit"
      :current-page="pager.page"
      :total="pager.totalCount"
      @current-change="handleCurrentChange"
      @size-change="handleSizeChange"
    />
    <!-- 添加修改弹窗 -->
    <el-dialog
      :title="titleMap[dialogType]"
      :close-on-click-modal="dialogType !== 'view' ? false : true"
      :visible.sync="dialogFormVisible"
      @close="resetTemp"
      width="800px"
      :key="'myDialog' + dialogIndex"
    >
      <el-form
        ref="dataForm"
        :model="temp"
        label-position="right"
        label-width="100px"
        :disabled="dialogType === 'view'"
      >
        <el-form-item
          label="主键"
          prop="rbId"
          :rules="[{ required: true, message: '主键不能为空' }]"
        >
          <el-input v-model="temp.rbId" placeholder="请输入主键" />
        </el-form-item>
        <el-form-item label="今日总结" prop="jrzj" :rules="[]">
          <el-input
            v-model="temp.jrzj"
            type="textarea"
            maxlength="65,535"
            placeholder="请输入今日总结"
          />
        </el-form-item>
        <el-form-item label="明日计划" prop="mrjh" :rules="[]">
          <el-input
            v-model="temp.mrjh"
            type="textarea"
            maxlength="65,535"
            placeholder="请输入明日计划"
          />
        </el-form-item>
        <el-form-item label="技术员id" prop="jsyId" :rules="[]">
          <el-input v-model="temp.jsyId" placeholder="请输入技术员id" />
        </el-form-item>
        <el-form-item label="技术员姓名" prop="jsyxm" :rules="[]">
          <el-input v-model="temp.jsyxm" placeholder="请输入技术员姓名" />
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button
          v-waves
          type="primary"
          v-if="dialogType !== 'view'"
          @click="saveData"
          >保存</el-button
        >
        <el-button v-waves @click="dialogFormVisible = false">取消</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import waves from "@/directive/waves";
import crudMixin from "@/mixin/crudMixin";

export default {
  directives: { waves },
  mixins: [crudMixin],
  data() {
    return {
      url: {
        list: "/jtnc/rbgl/krRbgl/list",
        add: "/jtnc/rbgl/krRbgl/add",
        info: "/jtnc/rbgl/krRbgl/getById",
        update: "/jtnc/rbgl/krRbgl/update",
        delete: "/jtnc/rbgl/krRbgl/delete",
        export: "/jtnc/rbgl/krRbgl/export/excel",
      },
    };
  },
  created() {
    this.loadTableList();
    this.resetTemp();
  },
  methods: {},
};
</script>
<style lang="scss" scoped>
.search-bar {
  margin-bottom: 10px;
  ::v-deep {
    .el-input,
    .el-select {
      width: 180px;
      margin-right: 10px;
      margin-bottom: 5px;
    }
  }
}
</style>
@/mixin/crudMixin
